package com.jic.veteran.portal.controller;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONObject;
import com.jic.veteran.common.api.CommonResult;
import com.jic.veteran.model.ProjectBasic;
import com.jic.veteran.portal.domain.ProjectBasicQueryParam;
import com.jic.veteran.portal.domain.ProjectDonationTotalDto;
import com.jic.veteran.portal.service.ProjectDonationService;
import com.jic.veteran.portal.service.ProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.math.BigDecimal;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Api(tags = "ProjectController")
@Controller
@RequestMapping("/project")
public class ProjectController {
    private static final Logger LOGGER = LoggerFactory.getLogger(ProjectController.class);

    @Autowired
    private ProjectService projectService;
    @Autowired private ProjectDonationService projectDonationService;
//
//    @ApiOperation("查询所有项目基本信息列表")
//    @RequestMapping(value = "/listAll", method = RequestMethod.GET)
//    @ResponseBody
//    public CommonResult<List<ProjectBasic>> listAll() {
//        List<ProjectBasic> projectBasicList = projectService.listAll();
//        return CommonResult.success(projectBasicList);
//    }
//
//    @ApiOperation("查询项目基本信息列表")
//    @RequestMapping(value = "/list", method = RequestMethod.POST)
//    @ResponseBody
//    public CommonResult<List<ProjectBasic>> list(ProjectBasicQueryParam projectBasicQueryParam,@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
//                                                 @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
//        List<ProjectBasic> projectBasicList = projectService.list(projectBasicQueryParam,pageSize,pageNum);
//        return CommonResult.success(projectBasicList);
//    }
//
//    @ApiOperation("根据id获取项目详情")
//    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
//    @ResponseBody
//    public CommonResult<JSONObject> getItem(@PathVariable Long id) {
//        JSONObject projectDto = projectService.getItem(id);
//        if(ObjectUtil.isEmpty(projectDto)) {
//            return CommonResult.failed("项目信息不存在");
//        }
//        return CommonResult.success(projectDto);
//    }
//
//    @ApiOperation("根据项目编号查询项目详情")
//    @RequestMapping(value = "/projectId/{projectId}", method = RequestMethod.GET)
//    @ResponseBody
//    public CommonResult<JSONObject> getItem(@PathVariable String projectId) {
//        JSONObject projectDto = projectService.getItemByProjectId(projectId);
//        if(ObjectUtil.isEmpty(projectDto)) {
//            return CommonResult.failed("项目信息不存在");
//        }
//        return CommonResult.success(projectDto);
//    }
//
//  @ApiOperation("根据项目编号查询项目捐赠情况")
//  @RequestMapping(value = "/actualFunding/{projectId}", method = RequestMethod.GET)
//  @ResponseBody
//  public CommonResult<ProjectDonationTotalDto> actualFunding(@PathVariable String projectId) {
//    ProjectDonationTotalDto totalDto = projectService.getActualFundingByProjectId(projectId);
//    if(ObjectUtil.isEmpty(totalDto)) {
//      totalDto = new ProjectDonationTotalDto();
//      totalDto.setProjectId(projectId);
//      totalDto.setProjectActualFunding(new BigDecimal("0.00"));
//      totalDto.setDonationCount(0);
//    }
//    return CommonResult.success(totalDto);
//  }
//
//  @ApiOperation("历史所有捐款总额和人次")
//  @RequestMapping(value = "/donationTotal", method = RequestMethod.GET)
//  @ResponseBody
//  public CommonResult<ProjectDonationTotalDto> donationTotal() {
//    return CommonResult.success(projectDonationService.getDonateTotal());
//  }
}
